package jsqlite.JDBC2z;

import androidx.exifinterface.media.ExifInterface;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.RowIdLifetime;
import java.sql.SQLException;
import java.util.Hashtable;
import jsqlite.Constants;
import jsqlite.Database;
import jsqlite.Exception;
import jsqlite.Shell;
import jsqlite.TableResult;

/* loaded from: classes2.dex */
public class JDBCDatabaseMetaData implements DatabaseMetaData {
    private JDBCConnection conn;

    static String mapTypeName(int i) {
        if (i != -3) {
            if (i != -2) {
                switch (i) {
                    case 4:
                        return "integer";
                    case 5:
                        return "smallint";
                    case 6:
                        return "float";
                    case 7:
                        return "real";
                    case 8:
                        return "double";
                    default:
                        switch (i) {
                            case 91:
                                return "date";
                            case 92:
                                return "time";
                            case 93:
                                return "timestamp";
                            default:
                                return "varchar";
                        }
                }
            }
            return "binary";
        }
        return "varbinary";
    }

    @Override // java.sql.DatabaseMetaData
    public boolean allProceduresAreCallable() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean allTablesAreSelectable() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean deletesAreDetected(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public String getCatalogSeparator() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public String getCatalogTerm() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public int getDatabaseMajorVersion() {
        return 1;
    }

    @Override // java.sql.DatabaseMetaData
    public int getDatabaseMinorVersion() {
        return Constants.drv_minor;
    }

    @Override // java.sql.DatabaseMetaData
    public String getDatabaseProductName() throws SQLException {
        return "SQLite";
    }

    @Override // java.sql.DatabaseMetaData
    public int getDefaultTransactionIsolation() throws SQLException {
        return 8;
    }

    @Override // java.sql.DatabaseMetaData
    public int getDriverMajorVersion() {
        return 1;
    }

    @Override // java.sql.DatabaseMetaData
    public int getDriverMinorVersion() {
        return Constants.drv_minor;
    }

    @Override // java.sql.DatabaseMetaData
    public String getDriverName() throws SQLException {
        return "SQLite/JDBC";
    }

    @Override // java.sql.DatabaseMetaData
    public String getDriverVersion() throws SQLException {
        return "1.20120209";
    }

    @Override // java.sql.DatabaseMetaData
    public String getExtraNameCharacters() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public String getIdentifierQuoteString() throws SQLException {
        return "\"";
    }

    @Override // java.sql.DatabaseMetaData
    public int getJDBCMajorVersion() {
        return 1;
    }

    @Override // java.sql.DatabaseMetaData
    public int getJDBCMinorVersion() {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxBinaryLiteralLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxCatalogNameLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxCharLiteralLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxColumnNameLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxColumnsInGroupBy() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxColumnsInIndex() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxColumnsInOrderBy() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxColumnsInSelect() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxColumnsInTable() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxConnections() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxCursorNameLength() throws SQLException {
        return 8;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxIndexLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxProcedureNameLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxRowSize() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxSchemaNameLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxStatementLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxStatements() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxTableNameLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxTablesInSelect() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public int getMaxUserNameLength() throws SQLException {
        return 0;
    }

    @Override // java.sql.DatabaseMetaData
    public String getNumericFunctions() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getProcedureColumns(String str, String str2, String str3, String str4) throws SQLException {
        return null;
    }

    @Override // java.sql.DatabaseMetaData
    public String getProcedureTerm() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getProcedures(String str, String str2, String str3) throws SQLException {
        return null;
    }

    @Override // java.sql.DatabaseMetaData
    public int getResultSetHoldability() throws SQLException {
        return 1;
    }

    @Override // java.sql.DatabaseMetaData
    public String getSQLKeywords() throws SQLException {
        return "SELECT,UPDATE,CREATE,TABLE,VIEW,DELETE,FROM,WHERE,COMMIT,ROLLBACK,TRIGGER";
    }

    @Override // java.sql.DatabaseMetaData
    public int getSQLStateType() throws SQLException {
        return 1;
    }

    @Override // java.sql.DatabaseMetaData
    public String getSchemaTerm() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public String getSearchStringEscape() throws SQLException {
        return "\\";
    }

    @Override // java.sql.DatabaseMetaData
    public String getStringFunctions() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public String getSystemFunctions() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public String getTimeDateFunctions() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getUDTs(String str, String str2, String str3, int[] iArr) throws SQLException {
        return null;
    }

    @Override // java.sql.DatabaseMetaData
    public String getUserName() throws SQLException {
        return "";
    }

    @Override // java.sql.DatabaseMetaData
    public boolean insertsAreDetected(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean isCatalogAtStart() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean isReadOnly() throws SQLException {
        return false;
    }

    @Override // java.sql.Wrapper
    public boolean isWrapperFor(Class cls) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean nullPlusNonNullIsNull() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean nullsAreSortedAtEnd() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean nullsAreSortedAtStart() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean nullsAreSortedHigh() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean nullsAreSortedLow() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean othersDeletesAreVisible(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean othersInsertsAreVisible(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean othersUpdatesAreVisible(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean ownDeletesAreVisible(int i) throws SQLException {
        return i == 1003 || i == 1004 || i == 1005;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean ownInsertsAreVisible(int i) throws SQLException {
        return i == 1003 || i == 1004 || i == 1005;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean ownUpdatesAreVisible(int i) throws SQLException {
        return i == 1003 || i == 1004 || i == 1005;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean storesLowerCaseIdentifiers() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean storesMixedCaseIdentifiers() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean storesUpperCaseIdentifiers() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsANSI92EntryLevelSQL() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsANSI92FullSQL() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsANSI92IntermediateSQL() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsAlterTableWithAddColumn() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsAlterTableWithDropColumn() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsBatchUpdates() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCatalogsInDataManipulation() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCatalogsInProcedureCalls() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCatalogsInTableDefinitions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsColumnAliasing() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsConvert() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsConvert(int i, int i2) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCoreSQLGrammar() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsCorrelatedSubqueries() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsDifferentTableCorrelationNames() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsExpressionsInOrderBy() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsExtendedSQLGrammar() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsFullOuterJoins() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsGetGeneratedKeys() {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsGroupBy() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsGroupByBeyondSelect() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsGroupByUnrelated() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsIntegrityEnhancementFacility() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsLikeEscapeClause() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsLimitedOuterJoins() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsMinimumSQLGrammar() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsMixedCaseIdentifiers() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsMultipleOpenResults() {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsMultipleResultSets() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsMultipleTransactions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsNamedParameters() {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsNonNullableColumns() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsOrderByUnrelated() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsOuterJoins() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsPositionedDelete() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsPositionedUpdate() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsResultSetConcurrency(int i, int i2) throws SQLException {
        if (i == 1003 || i == 1004 || i == 1005) {
            return i2 == 1007 || i2 == 1008;
        }
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsResultSetHoldability(int i) {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsResultSetType(int i) throws SQLException {
        return i == 1003 || i == 1004 || i == 1005;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSavepoints() {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSchemasInDataManipulation() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSchemasInIndexDefinitions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSchemasInProcedureCalls() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSchemasInTableDefinitions() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSelectForUpdate() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsStatementPooling() {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsStoredProcedures() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSubqueriesInComparisons() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSubqueriesInExists() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSubqueriesInIns() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsSubqueriesInQuantifieds() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsTableCorrelationNames() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsTransactionIsolationLevel(int i) throws SQLException {
        return i == 8;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsTransactions() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsUnion() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean supportsUnionAll() throws SQLException {
        return true;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean updatesAreDetected(int i) throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean usesLocalFilePerTable() throws SQLException {
        return false;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean usesLocalFiles() throws SQLException {
        return true;
    }

    public JDBCDatabaseMetaData(JDBCConnection jDBCConnection) {
        this.conn = jDBCConnection;
    }

    @Override // java.sql.DatabaseMetaData
    public String getURL() throws SQLException {
        return this.conn.url;
    }

    @Override // java.sql.DatabaseMetaData
    public String getDatabaseProductVersion() throws SQLException {
        return Database.version();
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getTables(String str, String str2, String str3, String[] strArr) throws SQLException {
        JDBCStatement jDBCStatement = new JDBCStatement(this.conn);
        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("SELECT '' AS 'TABLE_CAT', '' AS 'TABLE_SCHEM', tbl_name AS 'TABLE_NAME', upper(type) AS 'TABLE_TYPE', '' AS REMARKS FROM sqlite_master WHERE tbl_name like ");
        if (str3 != null) {
            stringBuffer.append(Shell.sql_quote(str3));
        } else {
            stringBuffer.append("'%'");
        }
        stringBuffer.append(" AND ");
        if (strArr == null || strArr.length == 0) {
            stringBuffer.append("(type = 'table' or type = 'view')");
        } else {
            stringBuffer.append("(");
            int i = 0;
            String str4 = "";
            while (i < strArr.length) {
                stringBuffer.append(str4);
                stringBuffer.append("type = ");
                stringBuffer.append(Shell.sql_quote(strArr[i].toLowerCase()));
                i++;
                str4 = " or ";
            }
            stringBuffer.append(")");
        }
        try {
            try {
                ResultSet executeQuery = jDBCStatement.executeQuery(stringBuffer.toString());
                jDBCStatement.close();
                return executeQuery;
            } catch (SQLException e) {
                throw e;
            }
        } finally {
            jDBCStatement.close();
        }
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getSchemas() throws SQLException {
        TableResult tableResult = new TableResult();
        tableResult.columns(new String[]{"TABLE_SCHEM"});
        tableResult.newrow(new String[]{""});
        return new JDBCResultSet(tableResult, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getCatalogs() throws SQLException {
        TableResult tableResult = new TableResult();
        tableResult.columns(new String[]{"TABLE_CAT"});
        tableResult.newrow(new String[]{""});
        return new JDBCResultSet(tableResult, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getTableTypes() throws SQLException {
        TableResult tableResult = new TableResult();
        tableResult.columns(new String[]{"TABLE_TYPE"});
        tableResult.newrow(new String[]{"TABLE"});
        tableResult.newrow(new String[]{"VIEW"});
        return new JDBCResultSet(tableResult, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getColumns(String str, String str2, String str3, String str4) throws SQLException {
        if (this.conn.db == null) {
            throw new SQLException("connection closed.");
        }
        JDBCStatement jDBCStatement = new JDBCStatement(this.conn);
        try {
            try {
                try {
                    this.conn.db.exec("SELECT 1 FROM sqlite_master LIMIT 1", null);
                    JDBCResultSet jDBCResultSet = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA table_info(" + Shell.sql_quote(str3) + ")");
                    jDBCStatement.close();
                    jDBCStatement.close();
                    int i = 1;
                    if (jDBCResultSet.tr.nrows < 1) {
                        throw new SQLException("no such table: " + str3);
                    }
                    int i2 = 18;
                    char c = 2;
                    char c2 = 3;
                    TableResultX tableResultX = new TableResultX();
                    tableResultX.columns(new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", "ORDINAL_POSITION", "IS_NULLABLE"});
                    tableResultX.sql_types(new int[]{12, 12, 12, 12, 5, 12, 4, 4, 4, 4, 4, 12, 12, 4, 4, 4, 4, 12});
                    JDBCResultSet jDBCResultSet2 = new JDBCResultSet(tableResultX, null);
                    if (jDBCResultSet != null && jDBCResultSet.tr != null && jDBCResultSet.tr.nrows > 0) {
                        Hashtable hashtable = new Hashtable();
                        int i3 = 0;
                        while (i3 < jDBCResultSet.tr.ncolumns) {
                            hashtable.put(jDBCResultSet.tr.column[i3], Integer.valueOf(i3));
                            i3++;
                            i2 = 18;
                            i = 1;
                            c = 2;
                            c2 = 3;
                        }
                        String str5 = (str4 == null || str4.charAt(0) != '%') ? str4 : null;
                        int i4 = 0;
                        while (i4 < jDBCResultSet.tr.nrows) {
                            String[] strArr = (String[]) jDBCResultSet.tr.rows.elementAt(i4);
                            int intValue = ((Integer) hashtable.get("name")).intValue();
                            if (str5 == null || strArr[intValue].compareTo(str5) == 0) {
                                String[] strArr2 = new String[i2];
                                strArr2[0] = "";
                                strArr2[i] = "";
                                strArr2[c] = str3;
                                strArr2[c2] = strArr[intValue];
                                String str6 = strArr[((Integer) hashtable.get("type")).intValue()];
                                int mapSqlType = mapSqlType(str6);
                                StringBuilder sb = new StringBuilder();
                                sb.append(mapSqlType);
                                strArr2[4] = sb.toString();
                                strArr2[5] = mapTypeName(mapSqlType);
                                StringBuilder sb2 = new StringBuilder();
                                sb2.append(getD(str6, mapSqlType));
                                strArr2[6] = sb2.toString();
                                StringBuilder sb3 = new StringBuilder();
                                sb3.append(getM(str6, mapSqlType));
                                strArr2[7] = sb3.toString();
                                strArr2[8] = "10";
                                strArr2[9] = "0";
                                strArr2[11] = null;
                                strArr2[12] = strArr[((Integer) hashtable.get("dflt_value")).intValue()];
                                strArr2[13] = "0";
                                strArr2[14] = "0";
                                strArr2[15] = "65536";
                                strArr2[16] = Integer.toString(Integer.parseInt(strArr[((Integer) hashtable.get("cid")).intValue()]) + i);
                                int intValue2 = ((Integer) hashtable.get("notnull")).intValue();
                                strArr2[17] = strArr[intValue2].charAt(0) == '0' ? "YES" : "NO";
                                strArr2[10] = strArr[intValue2].charAt(0) == '0' ? "1" : "0";
                                tableResultX.newrow(strArr2);
                            }
                            i4++;
                            i2 = 18;
                            i = 1;
                            c = 2;
                            c2 = 3;
                        }
                    }
                    return jDBCResultSet2;
                } catch (Exception unused) {
                    throw new SQLException("schema reload failed");
                }
            } catch (SQLException e) {
                throw e;
            }
        } catch (Throwable th) {
            jDBCStatement.close();
            throw th;
        }
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getColumnPrivileges(String str, String str2, String str3, String str4) throws SQLException {
        TableResultX tableResultX = new TableResultX();
        tableResultX.columns(new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", "IS_GRANTABLE"});
        tableResultX.sql_types(new int[]{12, 12, 12, 12, 12, 12, 12, 12});
        return new JDBCResultSet(tableResultX, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getTablePrivileges(String str, String str2, String str3) throws SQLException {
        TableResultX tableResultX = new TableResultX();
        tableResultX.columns(new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", "IS_GRANTABLE"});
        tableResultX.sql_types(new int[]{12, 12, 12, 12, 12, 12, 12, 12});
        return new JDBCResultSet(tableResultX, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getBestRowIdentifier(String str, String str2, String str3, int i, boolean z) throws SQLException {
        JDBCResultSet jDBCResultSet;
        JDBCDatabaseMetaData jDBCDatabaseMetaData = this;
        String str4 = ")";
        JDBCStatement jDBCStatement = new JDBCStatement(jDBCDatabaseMetaData.conn);
        JDBCStatement jDBCStatement2 = new JDBCStatement(jDBCDatabaseMetaData.conn);
        try {
            try {
                try {
                    jDBCDatabaseMetaData.conn.db.exec("SELECT 1 FROM sqlite_master LIMIT 1", null);
                    JDBCResultSet jDBCResultSet2 = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA index_list(" + Shell.sql_quote(str3) + ")");
                    JDBCResultSet jDBCResultSet3 = (JDBCResultSet) jDBCStatement2.executeQuery("PRAGMA table_info(" + Shell.sql_quote(str3) + ")");
                    jDBCStatement.close();
                    jDBCStatement2.close();
                    int i2 = 0;
                    TableResultX tableResultX = new TableResultX();
                    tableResultX.columns(new String[]{"SCOPE", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "PSEUDO_COLUMN"});
                    tableResultX.sql_types(new int[]{5, 12, 5, 12, 4, 4, 5, 5});
                    JDBCResultSet jDBCResultSet4 = new JDBCResultSet(tableResultX, null);
                    if (jDBCResultSet2 != null && jDBCResultSet2.tr != null && jDBCResultSet2.tr.nrows > 0 && jDBCResultSet3 != null && jDBCResultSet3.tr != null && jDBCResultSet3.tr.nrows > 0) {
                        Hashtable hashtable = new Hashtable();
                        int i3 = 0;
                        while (i3 < jDBCResultSet2.tr.ncolumns) {
                            hashtable.put(jDBCResultSet2.tr.column[i3], Integer.valueOf(i3));
                            i3++;
                            jDBCDatabaseMetaData = this;
                            str4 = str4;
                            i2 = 0;
                        }
                        Hashtable hashtable2 = new Hashtable();
                        int i4 = 0;
                        while (i4 < jDBCResultSet3.tr.ncolumns) {
                            hashtable2.put(jDBCResultSet3.tr.column[i4], Integer.valueOf(i4));
                            i4++;
                            jDBCDatabaseMetaData = this;
                            str4 = str4;
                            i2 = 0;
                        }
                        int i5 = 0;
                        while (i5 < jDBCResultSet2.tr.nrows) {
                            String[] strArr = (String[]) jDBCResultSet2.tr.rows.elementAt(i5);
                            String str5 = strArr[((Integer) hashtable.get("unique")).intValue()];
                            String str6 = "name";
                            String str7 = strArr[((Integer) hashtable.get("name")).intValue()];
                            if (str5.charAt(i2) != '0') {
                                JDBCStatement jDBCStatement3 = new JDBCStatement(jDBCDatabaseMetaData.conn);
                                try {
                                    jDBCResultSet = (JDBCResultSet) jDBCStatement3.executeQuery("PRAGMA index_info(" + Shell.sql_quote(str7) + str4);
                                    jDBCStatement3.close();
                                } catch (SQLException unused) {
                                    jDBCStatement3.close();
                                    jDBCResultSet = null;
                                } catch (Throwable th) {
                                    jDBCStatement3.close();
                                    throw th;
                                }
                                if (jDBCResultSet != null && jDBCResultSet.tr != null && jDBCResultSet.tr.nrows > 0) {
                                    Hashtable hashtable3 = new Hashtable();
                                    int i6 = 0;
                                    while (i6 < jDBCResultSet.tr.ncolumns) {
                                        hashtable3.put(jDBCResultSet.tr.column[i6], Integer.valueOf(i6));
                                        i6++;
                                        str4 = str4;
                                    }
                                    int i7 = 0;
                                    while (i7 < jDBCResultSet.tr.nrows) {
                                        String str8 = ((String[]) jDBCResultSet.tr.rows.elementAt(i7))[((Integer) hashtable3.get(str6)).intValue()];
                                        String str9 = str4;
                                        int i8 = 0;
                                        while (i8 < jDBCResultSet3.tr.nrows) {
                                            String str10 = str6;
                                            if (str8.compareTo(((String[]) jDBCResultSet3.tr.rows.elementAt(i8))[((Integer) hashtable2.get(str6)).intValue()]) == 0) {
                                                StringBuilder sb = new StringBuilder();
                                                sb.append(i);
                                                tableResultX.newrow(new String[]{sb.toString(), str8, "12", "VARCHAR", "65536", "0", "0", "1"});
                                            }
                                            i8++;
                                            str6 = str10;
                                        }
                                        i7++;
                                        str4 = str9;
                                    }
                                }
                            }
                            i5++;
                            jDBCDatabaseMetaData = this;
                            str4 = str4;
                            i2 = 0;
                        }
                    }
                    if (tableResultX.nrows <= 0) {
                        StringBuilder sb2 = new StringBuilder();
                        sb2.append(i);
                        tableResultX.newrow(new String[]{sb2.toString(), "_ROWID_", "4", "INTEGER", "10", "0", "0", "2"});
                    }
                    return jDBCResultSet4;
                } catch (SQLException e) {
                    throw e;
                }
            } catch (Exception unused2) {
                throw new SQLException("schema reload failed");
            }
        } catch (Throwable th2) {
            jDBCStatement.close();
            jDBCStatement2.close();
            throw th2;
        }
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getVersionColumns(String str, String str2, String str3) throws SQLException {
        TableResultX tableResultX = new TableResultX();
        tableResultX.columns(new String[]{"SCOPE", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "PSEUDO_COLUMN"});
        tableResultX.sql_types(new int[]{5, 12, 5, 12, 4, 4, 5, 5});
        return new JDBCResultSet(tableResultX, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getPrimaryKeys(String str, String str2, String str3) throws SQLException {
        JDBCResultSet jDBCResultSet;
        String str4 = ")";
        JDBCStatement jDBCStatement = new JDBCStatement(this.conn);
        try {
            try {
                try {
                    this.conn.db.exec("SELECT 1 FROM sqlite_master LIMIT 1", null);
                    JDBCResultSet jDBCResultSet2 = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA index_list(" + Shell.sql_quote(str3) + ")");
                    jDBCStatement.close();
                    int i = 6;
                    TableResultX tableResultX = new TableResultX();
                    tableResultX.columns(new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "KEY_SEQ", "PK_NAME"});
                    tableResultX.sql_types(new int[]{12, 12, 12, 12, 5, 12});
                    JDBCResultSet jDBCResultSet3 = new JDBCResultSet(tableResultX, null);
                    char c = '0';
                    if (jDBCResultSet2 != null && jDBCResultSet2.tr != null && jDBCResultSet2.tr.nrows > 0) {
                        Hashtable hashtable = new Hashtable();
                        int i2 = 0;
                        while (i2 < jDBCResultSet2.tr.ncolumns) {
                            hashtable.put(jDBCResultSet2.tr.column[i2], Integer.valueOf(i2));
                            i2++;
                            str4 = str4;
                            i = 6;
                            c = '0';
                        }
                        int i3 = 0;
                        while (i3 < jDBCResultSet2.tr.nrows) {
                            String[] strArr = (String[]) jDBCResultSet2.tr.rows.elementAt(i3);
                            String str5 = strArr[((Integer) hashtable.get("unique")).intValue()];
                            String str6 = strArr[((Integer) hashtable.get("name")).intValue()];
                            if (str5.charAt(0) != c) {
                                jDBCStatement = new JDBCStatement(this.conn);
                                try {
                                    jDBCResultSet = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA index_info(" + Shell.sql_quote(str6) + str4);
                                } catch (SQLException unused) {
                                    jDBCStatement.close();
                                    jDBCResultSet = null;
                                } catch (Throwable th) {
                                    throw th;
                                }
                                if (jDBCResultSet != null && jDBCResultSet.tr != null && jDBCResultSet.tr.nrows > 0) {
                                    Hashtable hashtable2 = new Hashtable();
                                    int i4 = 0;
                                    while (i4 < jDBCResultSet.tr.ncolumns) {
                                        hashtable2.put(jDBCResultSet.tr.column[i4], Integer.valueOf(i4));
                                        i4++;
                                        str4 = str4;
                                        i = 6;
                                    }
                                    int i5 = 0;
                                    while (i5 < jDBCResultSet.tr.nrows) {
                                        String[] strArr2 = (String[]) jDBCResultSet.tr.rows.elementAt(i5);
                                        String str7 = str4;
                                        String[] strArr3 = new String[i];
                                        strArr3[0] = "";
                                        strArr3[1] = "";
                                        strArr3[2] = str3;
                                        strArr3[3] = strArr2[((Integer) hashtable2.get("name")).intValue()];
                                        strArr3[4] = Integer.toString(Integer.parseInt(strArr2[((Integer) hashtable2.get("seqno")).intValue()]) + 1);
                                        strArr3[5] = str6;
                                        tableResultX.newrow(strArr3);
                                        i5++;
                                        str4 = str7;
                                        i = 6;
                                    }
                                }
                            }
                            i3++;
                            str4 = str4;
                            i = 6;
                            c = '0';
                        }
                    }
                    String str8 = str4;
                    if (tableResultX.nrows > 0) {
                        return jDBCResultSet3;
                    }
                    jDBCStatement = new JDBCStatement(this.conn);
                    try {
                        try {
                            JDBCResultSet jDBCResultSet4 = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA table_info(" + Shell.sql_quote(str3) + str8);
                            if (jDBCResultSet4 != null && jDBCResultSet4.tr != null && jDBCResultSet4.tr.nrows > 0) {
                                Hashtable hashtable3 = new Hashtable();
                                for (int i6 = 0; i6 < jDBCResultSet4.tr.ncolumns; i6++) {
                                    hashtable3.put(jDBCResultSet4.tr.column[i6], Integer.valueOf(i6));
                                }
                                for (int i7 = 0; i7 < jDBCResultSet4.tr.nrows; i7++) {
                                    String[] strArr4 = (String[]) jDBCResultSet4.tr.rows.elementAt(i7);
                                    if (strArr4[((Integer) hashtable3.get("type")).intValue()].equalsIgnoreCase("integer") && strArr4[((Integer) hashtable3.get("pk")).intValue()].charAt(0) != '0') {
                                        tableResultX.newrow(new String[]{"", "", str3, strArr4[((Integer) hashtable3.get("name")).intValue()], Integer.toString(Integer.parseInt(strArr4[((Integer) hashtable3.get("cid")).intValue()]) + 1), ""});
                                    }
                                }
                            }
                            return jDBCResultSet3;
                        } catch (SQLException e) {
                            throw e;
                        }
                    } finally {
                    }
                } catch (Exception unused2) {
                    throw new SQLException("schema reload failed");
                }
            } catch (SQLException e2) {
                throw e2;
            }
        } finally {
        }
    }

    private void internalImportedKeys(String str, String str2, JDBCResultSet jDBCResultSet, TableResultX tableResultX) {
        Hashtable hashtable = new Hashtable();
        for (int i = 0; i < jDBCResultSet.tr.ncolumns; i++) {
            hashtable.put(jDBCResultSet.tr.column[i], Integer.valueOf(i));
        }
        for (int i2 = 0; i2 < jDBCResultSet.tr.nrows; i2++) {
            String[] strArr = (String[]) jDBCResultSet.tr.rows.elementAt(i2);
            String str3 = strArr[((Integer) hashtable.get("table")).intValue()];
            if (str2 == null || str2.equalsIgnoreCase(str3)) {
                String str4 = strArr[((Integer) hashtable.get("from")).intValue()];
                String str5 = strArr[((Integer) hashtable.get("to")).intValue()];
                String str6 = strArr[((Integer) hashtable.get("seq")).intValue()];
                String[] strArr2 = new String[tableResultX.ncolumns];
                strArr2[0] = "";
                strArr2[1] = "";
                strArr2[2] = str3;
                strArr2[3] = str5;
                strArr2[4] = "";
                strArr2[5] = "";
                strArr2[6] = str;
                if (str4 == null) {
                    str4 = str5;
                }
                strArr2[7] = str4;
                strArr2[8] = Integer.toString(Integer.parseInt(str6) + 1);
                strArr2[9] = ExifInterface.GPS_MEASUREMENT_3D;
                strArr2[10] = ExifInterface.GPS_MEASUREMENT_3D;
                strArr2[11] = null;
                strArr2[12] = null;
                strArr2[13] = "7";
                tableResultX.newrow(strArr2);
            }
        }
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getImportedKeys(String str, String str2, String str3) throws SQLException {
        JDBCStatement jDBCStatement = new JDBCStatement(this.conn);
        try {
            try {
                try {
                    this.conn.db.exec("SELECT 1 FROM sqlite_master LIMIT 1", null);
                    JDBCResultSet jDBCResultSet = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA foreign_key_list(" + Shell.sql_quote(str3) + ")");
                    jDBCStatement.close();
                    TableResultX tableResultX = new TableResultX();
                    tableResultX.columns(new String[]{"PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY"});
                    tableResultX.sql_types(new int[]{12, 12, 12, 12, 12, 12, 12, 12, 5, 5, 5, 12, 12, 5});
                    JDBCResultSet jDBCResultSet2 = new JDBCResultSet(tableResultX, null);
                    if (jDBCResultSet != null && jDBCResultSet.tr != null && jDBCResultSet.tr.nrows > 0) {
                        internalImportedKeys(str3, null, jDBCResultSet, tableResultX);
                    }
                    return jDBCResultSet2;
                } catch (Exception unused) {
                    throw new SQLException("schema reload failed");
                }
            } catch (Throwable th) {
                jDBCStatement.close();
                throw th;
            }
        } catch (SQLException e) {
            throw e;
        }
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getExportedKeys(String str, String str2, String str3) throws SQLException {
        TableResultX tableResultX = new TableResultX();
        tableResultX.columns(new String[]{"PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY"});
        tableResultX.sql_types(new int[]{12, 12, 12, 12, 12, 12, 12, 12, 5, 5, 5, 12, 12, 5});
        return new JDBCResultSet(tableResultX, null);
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getCrossReference(String str, String str2, String str3, String str4, String str5, String str6) throws SQLException {
        JDBCResultSet jDBCResultSet;
        if (str6 == null || str6.charAt(0) == '%') {
            jDBCResultSet = null;
        } else {
            JDBCStatement jDBCStatement = new JDBCStatement(this.conn);
            try {
                try {
                    try {
                        this.conn.db.exec("SELECT 1 FROM sqlite_master LIMIT 1", null);
                        jDBCResultSet = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA foreign_key_list(" + Shell.sql_quote(str6) + ")");
                    } catch (Exception unused) {
                        throw new SQLException("schema reload failed");
                    }
                } catch (SQLException e) {
                    throw e;
                }
            } finally {
                jDBCStatement.close();
            }
        }
        TableResultX tableResultX = new TableResultX();
        tableResultX.columns(new String[]{"PKTABLE_CAT", "PKTABLE_SCHEM", "PKTABLE_NAME", "PKCOLUMN_NAME", "FKTABLE_CAT", "FKTABLE_SCHEM", "FKTABLE_NAME", "FKCOLUMN_NAME", "KEY_SEQ", "UPDATE_RULE", "DELETE_RULE", "FK_NAME", "PK_NAME", "DEFERRABILITY"});
        tableResultX.sql_types(new int[]{12, 12, 12, 12, 12, 12, 12, 12, 5, 5, 5, 12, 12, 5});
        JDBCResultSet jDBCResultSet2 = new JDBCResultSet(tableResultX, null);
        if (jDBCResultSet != null && jDBCResultSet.tr != null && jDBCResultSet.tr.nrows > 0) {
            if (str3 == null || str3.charAt(0) == '%') {
                str3 = null;
            }
            internalImportedKeys(str6, str3, jDBCResultSet, tableResultX);
        }
        return jDBCResultSet2;
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getTypeInfo() throws SQLException {
        TableResultX tableResultX = new TableResultX();
        tableResultX.columns(new String[]{"TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX", "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "NUM_PREC_RADIX"});
        tableResultX.sql_types(new int[]{12, 5, 4, 12, 12, 12, 5, -7, 5, -7, -7, -7, 12, 5, 5, 4, 4, 4});
        JDBCResultSet jDBCResultSet = new JDBCResultSet(tableResultX, null);
        String[] strArr = new String[18];
        strArr[0] = "VARCHAR";
        strArr[1] = "12";
        strArr[2] = "65536";
        strArr[3] = "'";
        strArr[4] = "'";
        strArr[6] = "1";
        strArr[7] = "1";
        strArr[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr[9] = "0";
        strArr[10] = "0";
        strArr[11] = "0";
        strArr[13] = "0";
        strArr[14] = "0";
        strArr[15] = "0";
        strArr[16] = "0";
        strArr[17] = "0";
        tableResultX.newrow(strArr);
        String[] strArr2 = new String[18];
        strArr2[0] = "INTEGER";
        strArr2[1] = "4";
        strArr2[2] = "32";
        strArr2[6] = "1";
        strArr2[7] = "0";
        strArr2[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr2[9] = "0";
        strArr2[10] = "0";
        strArr2[11] = "1";
        strArr2[13] = "0";
        strArr2[14] = "0";
        strArr2[15] = "0";
        strArr2[16] = "0";
        strArr2[17] = "2";
        tableResultX.newrow(strArr2);
        String[] strArr3 = new String[18];
        strArr3[0] = "DOUBLE";
        strArr3[1] = "8";
        strArr3[2] = "16";
        strArr3[6] = "1";
        strArr3[7] = "0";
        strArr3[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr3[9] = "0";
        strArr3[10] = "0";
        strArr3[11] = "1";
        strArr3[13] = "0";
        strArr3[14] = "0";
        strArr3[15] = "0";
        strArr3[16] = "0";
        strArr3[17] = "10";
        tableResultX.newrow(strArr3);
        String[] strArr4 = new String[18];
        strArr4[0] = "FLOAT";
        strArr4[1] = "6";
        strArr4[2] = "7";
        strArr4[6] = "1";
        strArr4[7] = "0";
        strArr4[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr4[9] = "0";
        strArr4[10] = "0";
        strArr4[11] = "1";
        strArr4[13] = "0";
        strArr4[14] = "0";
        strArr4[15] = "0";
        strArr4[16] = "0";
        strArr4[17] = "10";
        tableResultX.newrow(strArr4);
        String[] strArr5 = new String[18];
        strArr5[0] = "SMALLINT";
        strArr5[1] = "5";
        strArr5[2] = "16";
        strArr5[6] = "1";
        strArr5[7] = "0";
        strArr5[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr5[9] = "0";
        strArr5[10] = "0";
        strArr5[11] = "1";
        strArr5[13] = "0";
        strArr5[14] = "0";
        strArr5[15] = "0";
        strArr5[16] = "0";
        strArr5[17] = "2";
        tableResultX.newrow(strArr5);
        String[] strArr6 = new String[18];
        strArr6[0] = "BIT";
        strArr6[1] = "-7";
        strArr6[2] = "1";
        strArr6[6] = "1";
        strArr6[7] = "0";
        strArr6[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr6[9] = "0";
        strArr6[10] = "0";
        strArr6[11] = "1";
        strArr6[13] = "0";
        strArr6[14] = "0";
        strArr6[15] = "0";
        strArr6[16] = "0";
        strArr6[17] = "2";
        tableResultX.newrow(strArr6);
        String[] strArr7 = new String[18];
        strArr7[0] = "TIMESTAMP";
        strArr7[1] = "93";
        strArr7[2] = "30";
        strArr7[6] = "1";
        strArr7[7] = "0";
        strArr7[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr7[9] = "0";
        strArr7[10] = "0";
        strArr7[11] = "1";
        strArr7[13] = "0";
        strArr7[14] = "0";
        strArr7[15] = "0";
        strArr7[16] = "0";
        strArr7[17] = "0";
        tableResultX.newrow(strArr7);
        String[] strArr8 = new String[18];
        strArr8[0] = "DATE";
        strArr8[1] = "91";
        strArr8[2] = "10";
        strArr8[6] = "1";
        strArr8[7] = "0";
        strArr8[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr8[9] = "0";
        strArr8[10] = "0";
        strArr8[11] = "1";
        strArr8[13] = "0";
        strArr8[14] = "0";
        strArr8[15] = "0";
        strArr8[16] = "0";
        strArr8[17] = "0";
        tableResultX.newrow(strArr8);
        String[] strArr9 = new String[18];
        strArr9[0] = "TIME";
        strArr9[1] = "92";
        strArr9[2] = "8";
        strArr9[6] = "1";
        strArr9[7] = "0";
        strArr9[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr9[9] = "0";
        strArr9[10] = "0";
        strArr9[11] = "1";
        strArr9[13] = "0";
        strArr9[14] = "0";
        strArr9[15] = "0";
        strArr9[16] = "0";
        strArr9[17] = "0";
        tableResultX.newrow(strArr9);
        String[] strArr10 = new String[18];
        strArr10[0] = "BINARY";
        strArr10[1] = "-2";
        strArr10[2] = "65536";
        strArr10[6] = "1";
        strArr10[7] = "0";
        strArr10[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr10[9] = "0";
        strArr10[10] = "0";
        strArr10[11] = "1";
        strArr10[13] = "0";
        strArr10[14] = "0";
        strArr10[15] = "0";
        strArr10[16] = "0";
        strArr10[17] = "0";
        tableResultX.newrow(strArr10);
        String[] strArr11 = new String[18];
        strArr11[0] = "VARBINARY";
        strArr11[1] = "-3";
        strArr11[2] = "65536";
        strArr11[6] = "1";
        strArr11[7] = "0";
        strArr11[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr11[9] = "0";
        strArr11[10] = "0";
        strArr11[11] = "1";
        strArr11[13] = "0";
        strArr11[14] = "0";
        strArr11[15] = "0";
        strArr11[16] = "0";
        strArr11[17] = "0";
        tableResultX.newrow(strArr11);
        String[] strArr12 = new String[18];
        strArr12[0] = "REAL";
        strArr12[1] = "7";
        strArr12[2] = "16";
        strArr12[6] = "1";
        strArr12[7] = "0";
        strArr12[8] = ExifInterface.GPS_MEASUREMENT_3D;
        strArr12[9] = "0";
        strArr12[10] = "0";
        strArr12[11] = "1";
        strArr12[13] = "0";
        strArr12[14] = "0";
        strArr12[15] = "0";
        strArr12[16] = "0";
        strArr12[17] = "10";
        tableResultX.newrow(strArr12);
        return jDBCResultSet;
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getIndexInfo(String str, String str2, String str3, boolean z, boolean z2) throws SQLException {
        JDBCResultSet jDBCResultSet;
        JDBCDatabaseMetaData jDBCDatabaseMetaData = this;
        String str4 = ")";
        JDBCStatement jDBCStatement = new JDBCStatement(jDBCDatabaseMetaData.conn);
        try {
            try {
                try {
                    jDBCDatabaseMetaData.conn.db.exec("SELECT 1 FROM sqlite_master LIMIT 1", null);
                    JDBCResultSet jDBCResultSet2 = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA index_list(" + Shell.sql_quote(str3) + ")");
                    jDBCStatement.close();
                    int i = 13;
                    TableResultX tableResultX = new TableResultX();
                    tableResultX.columns(new String[]{"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION"});
                    tableResultX.sql_types(new int[]{12, 12, 12, -7, 12, 12, 5, 5, 12, 12, 4, 4, 12});
                    JDBCResultSet jDBCResultSet3 = new JDBCResultSet(tableResultX, null);
                    if (jDBCResultSet2 != null && jDBCResultSet2.tr != null && jDBCResultSet2.tr.nrows > 0) {
                        Hashtable hashtable = new Hashtable();
                        int i2 = 0;
                        while (i2 < jDBCResultSet2.tr.ncolumns) {
                            hashtable.put(jDBCResultSet2.tr.column[i2], Integer.valueOf(i2));
                            i2++;
                            jDBCDatabaseMetaData = this;
                            str4 = str4;
                            i = 13;
                        }
                        int i3 = 0;
                        while (i3 < jDBCResultSet2.tr.nrows) {
                            String[] strArr = (String[]) jDBCResultSet2.tr.rows.elementAt(i3);
                            String str5 = strArr[((Integer) hashtable.get("unique")).intValue()];
                            String str6 = strArr[((Integer) hashtable.get("name")).intValue()];
                            if (!z || str5.charAt(0) != '0') {
                                jDBCStatement = new JDBCStatement(jDBCDatabaseMetaData.conn);
                                try {
                                    jDBCResultSet = (JDBCResultSet) jDBCStatement.executeQuery("PRAGMA index_info(" + Shell.sql_quote(str6) + str4);
                                } catch (SQLException unused) {
                                    jDBCStatement.close();
                                    jDBCResultSet = null;
                                } catch (Throwable th) {
                                    throw th;
                                }
                                if (jDBCResultSet != null && jDBCResultSet.tr != null && jDBCResultSet.tr.nrows > 0) {
                                    Hashtable hashtable2 = new Hashtable();
                                    int i4 = 0;
                                    while (i4 < jDBCResultSet.tr.ncolumns) {
                                        hashtable2.put(jDBCResultSet.tr.column[i4], Integer.valueOf(i4));
                                        i4++;
                                        str4 = str4;
                                        i = 13;
                                    }
                                    int i5 = 0;
                                    while (i5 < jDBCResultSet.tr.nrows) {
                                        String[] strArr2 = (String[]) jDBCResultSet.tr.rows.elementAt(i5);
                                        String str7 = str4;
                                        String[] strArr3 = new String[i];
                                        strArr3[0] = "";
                                        strArr3[1] = "";
                                        strArr3[2] = str3;
                                        strArr3[3] = (str5.charAt(0) != '0' || (str6.charAt(0) == '(' && str6.indexOf(" autoindex ") > 0)) ? "0" : "1";
                                        strArr3[4] = "";
                                        strArr3[5] = str6;
                                        strArr3[6] = ExifInterface.GPS_MEASUREMENT_3D;
                                        strArr3[7] = Integer.toString(Integer.parseInt(strArr2[((Integer) hashtable2.get("seqno")).intValue()]) + 1);
                                        strArr3[8] = strArr2[((Integer) hashtable2.get("name")).intValue()];
                                        strArr3[9] = ExifInterface.GPS_MEASUREMENT_IN_PROGRESS;
                                        strArr3[10] = "0";
                                        strArr3[11] = "0";
                                        strArr3[12] = null;
                                        tableResultX.newrow(strArr3);
                                        i5++;
                                        str4 = str7;
                                        i = 13;
                                    }
                                }
                            }
                            i3++;
                            jDBCDatabaseMetaData = this;
                            str4 = str4;
                            i = 13;
                        }
                    }
                    return jDBCResultSet3;
                } catch (Exception unused2) {
                    throw new SQLException("schema reload failed");
                }
            } catch (SQLException e) {
                throw e;
            }
        } finally {
            jDBCStatement.close();
        }
    }

    @Override // java.sql.DatabaseMetaData
    public Connection getConnection() throws SQLException {
        return this.conn;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public static int mapSqlType(String str) {
        if (str == null) {
            return 12;
        }
        String lowerCase = str.toLowerCase();
        if (lowerCase.startsWith("inter")) {
            return 12;
        }
        if (lowerCase.startsWith("numeric") || lowerCase.startsWith("int")) {
            return 4;
        }
        if (lowerCase.startsWith("tinyint") || lowerCase.startsWith("smallint")) {
            return 5;
        }
        if (lowerCase.startsWith("float")) {
            return 6;
        }
        if (lowerCase.startsWith("double")) {
            return 8;
        }
        if (lowerCase.startsWith("datetime") || lowerCase.startsWith("timestamp")) {
            return 93;
        }
        if (lowerCase.startsWith("date")) {
            return 91;
        }
        if (lowerCase.startsWith("time")) {
            return 92;
        }
        if (lowerCase.startsWith("blob") || lowerCase.startsWith("binary")) {
            return -2;
        }
        if (lowerCase.startsWith("varbinary")) {
            return -3;
        }
        return lowerCase.startsWith("real") ? 7 : 12;
    }

    static int getM(String str, int i) {
        int i2;
        switch (i) {
            case 4:
                i2 = 11;
                break;
            case 5:
                i2 = 6;
                break;
            case 6:
                i2 = 25;
                break;
            case 7:
            case 8:
                i2 = 54;
                break;
            default:
                switch (i) {
                    case 91:
                        return 10;
                    case 92:
                        return 8;
                    case 93:
                        return 30;
                    default:
                        i2 = 65536;
                        break;
                }
        }
        String lowerCase = str.toLowerCase();
        int indexOf = lowerCase.indexOf(40);
        if (indexOf > 0) {
            int i3 = indexOf + 1;
            int indexOf2 = lowerCase.indexOf(44, i3);
            if (indexOf2 < 0) {
                indexOf2 = lowerCase.indexOf(41, i3);
            }
            if (indexOf2 - i3 > 0) {
                try {
                    return Integer.parseInt(lowerCase.substring(i3, indexOf2), 10);
                } catch (NumberFormatException unused) {
                    return i2;
                }
            }
            return i2;
        }
        return i2;
    }

    static int getD(String str, int i) {
        int i2;
        switch (i) {
            case 4:
                i2 = 10;
                break;
            case 5:
                i2 = 5;
                break;
            case 6:
                i2 = 24;
                break;
            case 7:
            case 8:
                i2 = 53;
                break;
            default:
                return getM(str, i);
        }
        String lowerCase = str.toLowerCase();
        int indexOf = lowerCase.indexOf(40);
        if (indexOf > 0) {
            int indexOf2 = lowerCase.indexOf(44, indexOf + 1);
            if (indexOf2 < 0) {
                return getM(lowerCase, i);
            }
            int indexOf3 = lowerCase.indexOf(41, indexOf2);
            if (indexOf3 - indexOf2 > 0) {
                try {
                    return Integer.parseInt(lowerCase.substring(indexOf2, indexOf3), 10);
                } catch (NumberFormatException unused) {
                    return i2;
                }
            }
            return i2;
        }
        return i2;
    }

    @Override // java.sql.DatabaseMetaData
    public boolean locatorsUpdateCopy() throws SQLException {
        throw new SQLException("not supported");
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getSuperTypes(String str, String str2, String str3) throws SQLException {
        throw new SQLException("not supported");
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getSuperTables(String str, String str2, String str3) throws SQLException {
        throw new SQLException("not supported");
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getAttributes(String str, String str2, String str3, String str4) throws SQLException {
        throw new SQLException("not supported");
    }

    @Override // java.sql.DatabaseMetaData
    public RowIdLifetime getRowIdLifetime() throws SQLException {
        return RowIdLifetime.ROWID_UNSUPPORTED;
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getSchemas(String str, String str2) throws SQLException {
        throw new SQLException("not supported");
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getClientInfoProperties() throws SQLException {
        throw new SQLException("unsupported");
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getFunctions(String str, String str2, String str3) throws SQLException {
        throw new SQLException("unsupported");
    }

    @Override // java.sql.DatabaseMetaData
    public ResultSet getFunctionColumns(String str, String str2, String str3, String str4) throws SQLException {
        throw new SQLException("unsupported");
    }

    @Override // java.sql.Wrapper
    public <T> T unwrap(Class<T> cls) throws SQLException {
        throw new SQLException("unsupported");
    }
}
